package com.cote.douhahou.pretloan.msg.widget;

import static android.view.View.GONE;
import static android.view.View.VISIBLE;

import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.cote.douhahou.pretloan.beans.ProcesAkomapalendsInfoData;
import com.cote.douhahou.pretloan.network.HttpHelper;
import com.cote.douhahou.pretloan.R;


public class GeAkomapalendnderSelectViewManager extends BaseProcAkomapalendessWidgetManager {

    private TextView titl_akomapalendeTv;
    private TextView mal_akomapalendeTv, femal_akomapalendeTv;
    private ImageView mal_akomapalendeIv, fema_akomapalendleIv;

    private boolean isMa_akomapalendle = true;

    public GeAkomapalendnderSelectViewManager(View view, ProcesAkomapalendsInfoData data, String pageTag){
        super(view,data,pageTag);
    }

    @Override
    protected void in_akomapalendit(){

        titl_akomapalendeTv = mVi_akomapalendew.findViewById(R.id.vpga_tv_title);

        mal_akomapalendeTv = mVi_akomapalendew.findViewById(R.id.vpga_tv_male);
        femal_akomapalendeTv = mVi_akomapalendew.findViewById(R.id.vpga_tv_female);
        mal_akomapalendeIv = mVi_akomapalendew.findViewById(R.id.vpga_iv_male);
        fema_akomapalendleIv = mVi_akomapalendew.findViewById(R.id.vpga_iv_female);

        mVi_akomapalendew.findViewById(R.id.vpga_view_male).setOnClickListener(v -> setGender_akomapalend(true));
        mVi_akomapalendew.findViewById(R.id.vpga_view_female).setOnClickListener(v -> setGender_akomapalend(false));

        setTi_akomapalendtle(mDa_akomapalendta.getTitle_akomapalend());

    }

    @Override
    public boolean checkI_akomapalendnput() {
        return true;
    }

    @Override
    public String getInp_akomapalendut() {
        return isMa_akomapalendle ? "MALE":"FEMALE";
    }

    public void setGender_akomapalend(boolean isMale){
        this.isMa_akomapalendle = isMale;
        if (isMale){
            mal_akomapalendeTv.setTextColor(Color.BLACK);
            mal_akomapalendeIv.setBackgroundResource(R.drawable.icon_check_4);
            femal_akomapalendeTv.setTextColor(Color.parseColor("#FF999999"));
            fema_akomapalendleIv.setBackgroundResource(R.drawable.icon_no_check);
        }else {
            femal_akomapalendeTv.setTextColor(Color.BLACK);
            fema_akomapalendleIv.setBackgroundResource(R.drawable.icon_check_4);
            mal_akomapalendeTv.setTextColor(Color.parseColor("#FF999999"));
            mal_akomapalendeIv.setBackgroundResource(R.drawable.icon_no_check);
        }

        HttpHelper.inst().submitEvent(pa_akomapalendge, mDa_akomapalendta.getParamName_akomapalend().toUpperCase()+"_CLICK", getInp_akomapalendut());
    }

    public void setTi_akomapalendtle(String title){
        if (TextUtils.isEmpty(title)) titl_akomapalendeTv.setVisibility(GONE);
        else {
            titl_akomapalendeTv.setVisibility(VISIBLE);
            titl_akomapalendeTv.setText(title);
        }
    }

}
